const unifiedPay = (data, order, JumpUrl, paymentType) => {
	if (order.paymentPrice <= 0) {
		uni.navigateTo({
			url: JumpUrl
		})

	} else {
		console.log("预支付回参==========" + JSON.stringify(data));
		// #ifdef MP-WEIXIN
		uni.requestPayment({
			provider: 'wxpay',
			timeStamp: data.timeStamp,
			nonceStr: data.nonceStr,
			package: data.packageValue,
			signType: data.signType,
			paySign: data.paySign,
			success: function(res) {
				uni.navigateTo({
					url: JumpUrl
				})
			},
			fail: function(err) {
				uni.showModal({
					title: '提示',
					content: JSON.stringify(err),
					success(res) {}
				});
			}
		});
		// #endif
		// #ifdef MP-ALIPAY
		uni.requestPayment({
			provider: 'alipay',
			orderInfo: data.tradeNo,
			success: function(res) {
				if (!res.resultCode == '9000') {
					uni.showModal({
						title: '提示',
						content: res.memo,
						success(res) {}
					});
				} else {
					uni.navigateTo({
						url: JumpUrl
					})
				}

			},
			fail: function(err) {
				uni.showModal({
					title: '提示',
					content: JSON.stringify(err),
					success(res) {}
				});
			}
		});
		// #endif

		// #ifdef APP-PLUS
		let orderInfo = {
			"appid": data.appid,
			"noncestr": data.noncestr,
			"package": data.packageValue,
			"partnerid": data.partnerId,
			"prepayid": data.prepayId,
			"timestamp": data.timestamp,
			"sign": data.sign
		}
		if (paymentType == '1') {
			uni.requestPayment({
				"provider": "wxpay",
				"orderInfo": JSON.stringify(orderInfo),
				success(res) {
					uni.navigateTo({
						url: JumpUrl
					})
				},
				fail(e) {
					uni.showModal({
						title: '提示',
						content: JSON.stringify(e),
						success(res) {}
					});
				}
			})
		} else {
			uni.requestPayment({
				provider: 'alipay',
				orderInfo: data.body,
				success(res) {
					uni.navigateTo({
						url: JumpUrl
					})
				},
				fail(e) {
					uni.showModal({
						title: '提示',
						content: JSON.stringify(e),
						success(res) {}
					});
				}
			})
		}

		// #endif
	}

}
module.exports = {
	unifiedPay: unifiedPay
};
